package com.yt.lxh.search.controller;

import com.yt.lxh.common.result.ResponseResult;
import com.yt.lxh.common.result.ResultCodeEnum;
import com.yt.lxh.vo.product.SkuVO;
import com.yt.lxh.search.service.SkuService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(tags = "商品搜索接口")
@RestController
@RequestMapping("/search/sku")
@CrossOrigin
public class SkuSearchController {

    @Autowired
    private SkuService skuService;

    @ApiOperation("根据关键字搜索商品")
    @GetMapping("/{keyword}")
    public ResponseResult findSkuByKeyword(@PathVariable String keyword) {
        List<SkuVO> skuVOS = skuService.findSkuByKeyword(keyword);
        return ResponseResult.ok(ResultCodeEnum.SUCCESS, skuVOS);
    }

}
